<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/tld/dictionary" prefix="dictionary"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>收款</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="stylesheet" href="${ctx}/static/css/style.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/style1.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/kongjian.css" type="text/css" />
<link rel="stylesheet" href="${ctx}/static/css/jquery.ui.all.css" />
<link rel="stylesheet" href="${ctx}/static/css/m.css" />
<script src="${ctx}/static/script/jquery-1.4.min.js" type="text/javascript"></script>
<script src="${ctx}/static/script/jquery.ui.core.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx}/static/My97DatePicker/WdatePicker.js"></script>
<script src="${ctx}/static/script/jquery.form.js"></script>
<script src="${ctx}/static/script/jsCoreUtil.js"></script>
<script type="text/javascript" src="${ctx}/static/script/jquery.blockUI.js" ></script>
<script language="javascript">
function bb(x){
	if(x==2){
		ajaxsubmitPayList();
	}
	for(i=1;i<3;i++){
		
		document.getElementById("t"+i).style.display="none";
		document.getElementById("a_m"+i).style.background="#fff";
		}
		document.getElementById("t"+x).style.display="block";
		document.getElementById("a_m"+x).style.background="#c6defa";
	}
	Date.prototype.pattern=function(fmt) {        
    var o = {        
    "M+" : this.getMonth()+1, //月份        
    "d+" : this.getDate(), //日        
    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时        
    "H+" : this.getHours(), //小时        
    "m+" : this.getMinutes(), //分        
    "s+" : this.getSeconds(), //秒        
    "q+" : Math.floor((this.getMonth()+3)/3), //季度        
    "S" : this.getMilliseconds() //毫秒        
    };        
    var week = {        
    "0" : "\u65e5",        
    "1" : "\u4e00",        
    "2" : "\u4e8c",        
    "3" : "\u4e09",        
    "4" : "\u56db",        
    "5" : "\u4e94",        
    "6" : "\u516d"     
    };        
    if(/(y+)/.test(fmt)){        
            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));        
    }        
    if(/(E+)/.test(fmt)){        
            fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "\u661f\u671f" : "\u5468") : "")+week[this.getDay()+""]);        
    }        
    for(var k in o){        
            if(new RegExp("("+ k +")").test(fmt)){        
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));        
            }        
    }        
    return fmt;        
}
</script>
</head>

<body style="margin:10px;">
<form:form id="mainform1" action="${ctx}/order/order_receivables_ajax"  modelAttribute="orderForm" method="post" >
<p style=" text-align:left; height:30px; padding:0 10px; line-height:30px; border:#3b97e4 solid 1px;">
交易单编号：${orderForm.id}
投资编号：${orderForm.investInfo.id}
购买人客户编号：${orderForm.investInfo.customerInfo.customerCode}
购买人客户姓名：${orderForm.investInfo.customerInfo.cnName}
交易金额：<fmt:formatNumber value="${orderForm.orderAmt}" pattern="##,###.##"/></p>
<div style="height:10px;"></div>
<p><a id="a_m1"  class="a_m">收款单信息</a><!-- onclick="bb(1)" -->
<a id="a_m2"  class="a_m" style="background:#fff; border-left:0;">付款单明细</a></p><!-- onclick="bb(2)" -->
<div style="clear:both;"></div>
<input type="hidden" id="id" name="id" value="${orderForm.id}" />	
<input type="hidden" id="sysCurrentDate" name="sysCurrentDate" value="${orderForm.exportdate}" />	
<div id="errormsg_show_div" class="notification error png_bg" style="display:none;" >
	<a href="#" class="close"><img src="${ctx}/static/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
	<font color='red'><div id='errormsg_info_div'  align='left'></div></font>
</div>
<div id="output2"></div>
<div style=" border:#3b97e4 solid 1px; padding:10px 0 20px;" id="t1">
<table class="m_table">
	<tr>
        <td>订单编号：${orderForm.id}</td><td>投资编号：${orderForm.investInfo.id}</td>
	</tr>
	<tr>
        <td>客户编号：${orderForm.investInfo.customerInfo.customerCode}</td><td>客户姓名：${orderForm.investInfo.customerInfo.cnName}</td>
	</tr>
	<tr>
        <td>推荐对价金额：
        <fmt:formatNumber value="${orderForm.orderAmt}" pattern="##,###.##"></fmt:formatNumber>
        </td><td>约定交割日期：<fmt:formatDate value="${orderForm.appointPaymentDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" /></td>
	</tr>
	<tr>
        <td colspan="2">应付款金额：<fmt:formatNumber value="${orderForm.orderAmt}" pattern="##,###.##"></fmt:formatNumber></td>
	</tr>
	<tr>
        <td colspan="2">已付款金额：<fmt:formatNumber value="${orderForm.paymentAmt}" pattern="##,###.##"></fmt:formatNumber>
        （现金：<fmt:formatNumber value="${orderForm.cashAmt}" pattern="##,###.##"></fmt:formatNumber>
        非现金：<fmt:formatNumber value="${orderForm.reinvestAmt}" pattern="##,###.##"></fmt:formatNumber>）</td>
	</tr>
	<tr>
        <td colspan="2">收款金额：
       <fmt:formatNumber value="${orderForm.paymentAmt}" pattern="##,###.##"></fmt:formatNumber>
        </td>
	</tr>
	<tr>
        <td colspan="2">到款日期：<input type="text" id="deliveryDate"  style="width:70px;" name="deliveryDate" value="" onClick="WdatePicker()" readonly="true"/>
	<font color="red"><div id="deliveryDatediv" style="display:none;">到账日期不能为空</div></font></td>
	</tr>
	<tr>
        <td colspan="2"><span style="float:left;">备注：</span><textarea style="width:500px; height:80px;" id="memo" name="memo"></textarea></td>
	</tr>
	<tr>
	    <td colspan="2"><a href="#" id='RecAmtExec' class="btn1" style="margin-right:15px;">收款</a>
	    <a href="#" onclick="history.back();" class="btn1">取消</a></td>
	</tr>
</table>
</div>
	</form:form>
	<form:form id="mainform2" action="#" modelAttribute="billForm"  method="post">
<div id="output2"></div>
<input type="hidden" id="orderId" name="orderId" value="${orderForm.id}" />
<div style=" border:#3b97e4 solid 1px; padding:10px 0 20px;" id="t2">
	<div class="yiban">
	<p id="mainform2table_div"></p>
	</div>
<div class="ggkj_pagecontainer">
  <div class="ggkj_pageBGleft">
    	<span class="ggkj_pageBGright"></span>
    	<a href="javascript:jumpPage2(1)" class="ggkj_pageUpa">
        
        </a>
        <a href="javascript:jumpPage2(mainform2_page.prePage)" class="ggkj_pageUp">
        
        </a>
        <span class="ggkj_insertline"></span>
        <span class="ggkj_pageSpan">
        	页
        	<input type="text" id="pageNo" name="pageNo" value="1" class="ggkj_inputtext_30"/>OF <span id="totalPages3"></span>
        </span>
        <span class="ggkj_insertline"></span>
        <a href="javascript:jumpPage2(mainform2_page.nextPage)" class="ggkj_pageDown">
        
        </a>
        <a href="javascript:jumpPage2(mainform2_page.totalPages)" class="ggkj_pageDowna">
        
        </a>
        <span class="ggkj_insertline"></span>
        
    </div>
</div>
	</form:form>
</div>
<script language="JavaScript">
var mainform2_page;
function recOrderAjaxsubmit(){
	var options = {   
        target:     '#output2',   // target element(s) to be updated with server response   
        success: billRecv,
        url:        '${ctx}/order/order_receivables_ajax',      // override for form's 'action' attribute   
        type:       'post',       // 'get' or 'post', override for form's 'method' attribute   
        timeout: 10000   
    };  
    
     function submitt() {   
        $('#mainform1').ajaxSubmit(options);   
        return false;   
    };  
    submitt();
}

function billRecv(responseText)  {
	var mainform1 = document.getElementById("mainform1");
	var errormsg ;
	if(responseText.errorInfo==null){
		errormsg=responseText.errorMsg;
	}else{
		errormsg = responseText.errorInfo;
	}
	if(!showErrorMsg(errormsg,mainform1,'errormsg_show_div','errormsg_info_div')){
		bb(2);
	}
}

function mainform2Title(){
	var th = "<tr>";
	 th= th + '<th scope="col">序号</th>'
	 th= th + '<th scope="col">订单编号</th>'
	 th= th + '<th scope="col">付款单编号</th>'
	 th= th + '<th scope="col">汇入账户名</th>'
	 th= th + '<th scope="col">汇入银行</th>'
	 th= th + '<th scope="col">汇入账号</th>'
	 th= th + '<th scope="col">汇入金额</th>'
	 th= th + '<th scope="col">实际付款日期</th>'
	 th= th + '<th scope="col">收款日期</th>'
	 th= th + '<th scope="col">状态</th>'
	 th= th +'</tr>';
	 return th;
}
function mainform2InserRows(tbIndex,data){
	 var cssName = '';
	 var td = '';
	 if(Number(tbIndex)%2==1){
	 	cssName = 'ggkj_tdColr';
	 }else{
	 	cssName = '';
	 }
	 td = td + "<tr class='"+cssName+"' >";
	 td = td + "<td>"+tbIndex+"</td>";
	 td = td + "<td>"+data.ftOrderMain.id+"</td>";
	 td = td + "<td>"+data.id+"</td>";
	 td = td + "<td>"+data.recBankInfo.accName+"</td>";
	 td = td + "<td>"+dictionary.get(data.recBankInfo.bankName)+data.recBankInfo.subbranch+"</td>";//data.payBankInfo.bankName
	 td = td + "<td>"+data.recBankInfo.accNo+"</td>";//data.payBankInfo.accNo
	 td = td + "<td>"+formatCurrency(data.amt)+"</td>";
	 td = td + "<td>"+(new Date(data.ftOrderMain.deliveryDate)).pattern("yyyy-MM-dd")+"</td>";
	 td = td + "<td>"+(new Date(data.createDate)).pattern("yyyy-MM-dd")+"</td>";
	 td = td + "<td>"+dictionary.get(data.ftOrderMain.flowId)+"</td>";
	 return td;
}
function mainform2Response(responseText, statusText, xhr, $form){
	var thisformm = document.getElementById('mainform2');
	mainform2_page = responseText;
	var table ='<table style="width:100%;" class="ggkj_table"  border="0" cellspacing="0" cellpadding="0">';
	table = table + mainform2Title();
	if(mainform2_page!=null){
		thisformm.pageNo.value=mainform2_page.pageNo;
		$('#totalPages3').text(responseText.totalPages);
		for(var i=0;i<responseText.result.length;i++){
			table = table + mainform2InserRows(i+1,responseText.result[i]);
		}
	}
	table = table + '</table>';
	document.getElementById('mainform2table_div').innerHTML = table;
	return ;
}
function ajaxsubmitPayList(){
    var options = {   
        target:        '#output2',   // target element(s) to be updated with server response   
        success:       mainform2Response, // post-submit callback   
        url:        '${ctx}/bill/bill_list',      // override for form's 'action' attribute   
        type:       'post',       // 'get' or 'post', override for form's 'method' attribute   
        dataType:   'json'       // 'xml', 'script', or 'json' (expected server response type)
    };   
     // bind to the form's submit event   
    function submitt() {   
        $('#mainform2').ajaxSubmit(options);   
        return false;   
    };  
    submitt();
}
 // unblock when ajax activity stops 
$(document).ajaxStop($.unblockUI); 
$(document).ready(function() { 
    $('#RecAmtExec').click(function() { 
		if(document.getElementById('deliveryDate').value==null||document.getElementById('deliveryDate').value==''){
			document.getElementById('deliveryDatediv').style.display = '';
			return ;
		}else{
			if(compareDate(GetInputValue('sysCurrentDate'),GetInputValue('deliveryDate') )){
				alert('收款确认日期不能是未来时间!');
				return ;
			}
			document.getElementById('deliveryDatediv').style.display = 'none';
		}
		if($("#memo").val().length>50){
		    alert("备注不能超过50个字符！");
		    return ;
		}
		      
	  	$.blockUI({ message: '<div><img src="${ctx}/static/images/busy.gif" /><font size="4px"> Just a moment...</font></div>' }); 
	  	recOrderAjaxsubmit();
    }); 
});

$(document).ready(function() { 
	dictionary = dictionaryInit();
	//ajaxsubmitPayList();
}); 
</script>
</body>
</html>

